package com.weepal.pavement.mqtt.demo.job;

import com.weepal.pavement.mqtt.demo.vo.MqttDevices;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class MqttDevicesMap {
    public static ConcurrentHashMap<String, MqttDevices> deviceMap = new ConcurrentHashMap<>(16);

    public static void setDevice(MqttDevices device) {
        deviceMap.put(device.getSubGateway(), device);
    }

    public static void setDevices(List<MqttDevices> devices) {
        for (MqttDevices mqttDevices : devices) {
            deviceMap.put(mqttDevices.getSubGateway(), mqttDevices);
        }
    }

    public static MqttDevices getDevicd(String subTopic) {
        return deviceMap.get(subTopic);
    }
}
